package com.lct.demo;

public class MethodTest1 {
    public static void main(String[] args) {
        //使用方法求1-n的和并返回

        System.out.println(getSum(100));
    }

    //定义方法求和
    public static int getSum(int n){
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += i;
        }
        return sum;
    }
}
